package com.heima.admin.controller.v1;

import com.heima.admin.service.ChannelService;
import com.heima.model.admin.dtos.WmChannelPageReqDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {

    @Autowired
    private ChannelService channelService;

    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return channelService.saveChannel(wmChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id){

        return channelService.deleteChannel(id);
    }

    @PostMapping("/list")
    public ResponseResult pageChannel(@RequestBody WmChannelPageReqDto dto){
        return channelService.pageChannel(dto);
    }

    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel){
        return channelService.updateChannel(wmChannel);
    }
}
